<?php

namespace App\Http\Controllers;

use App\Http\Controllers\BaseController;
use App\Services\VolunteerFormService;
use Illuminate\Http\Request;

class VolunteerFormController extends BaseController
{
    public function __construct(VolunteerFormService $volunteerFormService)
    {
        $this->middleware('check.login')->except('index');

        $this->volunteerFormService = $volunteerFormService;
    }

    public function store(Request $request)
    {
        $param = $this->validationParameter([
            'volunteer_id|志愿活动id' => 'require',
            'name|姓名' => 'require',
            'sex|性别' => 'require',
            'age|年龄' => 'require',
            'phone|手机' => 'require',
            'id_card|身份证号' => 'require',
            'work_unit|工作单位' => 'require',
            'address|住址' => 'require',
        ]);
        $param['add_uid'] = $request->user('api')->user_id ?? null;

        $result = $this->volunteerFormService->add($param);

        return $this->response->success($result);
    }

    public function my(Request $request)
    {
        $param['add_uid'] = $request->user('api')->user_id ?? null;

        $result = $this->volunteerFormService->getList($param);

        return $this->response->success($result);

    }
}
